package com.infocollect.project.api.ui;

import com.infocollect.project.api.req.DelActionRoleReq;
import com.infocollect.project.api.req.TappActionRoleReq;
import com.infocollect.project.api.service.ITappActionRoleService;
import com.infocollect.project.api.vo.ActionRoleVO;
import com.infocollect.project.form.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * (TappActins)角色菜单按钮权限
 *
 * @author makejava
 * @since 2019-12-25 10:32:28
 */
@Api(value = "TappActionRole", tags = "角色菜单按钮权限")
@RestController
@RequestMapping("actionRole")
public class TappActionRoleController {
    @Autowired
    private ITappActionRoleService actionRoleService;

    /**
     * 角色菜单按钮
     *
     * @param req
     * @return
     */
    @ApiOperation("保存角色菜单按钮")
    @PostMapping("saveActionRole")
    public R<String> saveActionRole(@RequestBody TappActionRoleReq req) {
        return actionRoleService.saveActionRole(req);
    }



    /**
     * 根据ID 删除角色菜单动作权限
     *
     * @param
     * @return
     */
    @ApiOperation("根据ID 删除角色菜单动作权限")
    @PostMapping("delActionRole")
    public R<String> delActionRole(@RequestBody DelActionRoleReq param) {
        if(param.getId()==null){
            return R.newError("传入参数有误！");
        }
        return actionRoleService.delActionRole(param);
    }

    /**
     * 根据角色ID 获取角色菜单动作权限
     *
     * @param
     * @return
     */
    @ApiOperation("根据角色ID 获取角色菜单动作权限")
    @PostMapping("queryByRoleMenuId")
    public R<List<ActionRoleVO>> queryByRoleMenuId(@RequestParam("roleId") Long roleId, @RequestParam("menuId") Long menuId) {
        return R.newOk(actionRoleService.queryByRoleMenuId(roleId,menuId));
    }


}

